package com.cdtu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdtu.entity.OperationRecord;
import com.cdtu.service.OperationRecordService;
import com.cdtu.mapper.OperationRecordMapper;
import com.cdtu.vo.OperationRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Sakura
* @description 针对表【op_record】的数据库操作Service实现
* @createDate 2023-01-08 12:38:04
*/
@Service
public class OperationRecordServiceImpl extends ServiceImpl<OperationRecordMapper, OperationRecord>
    implements OperationRecordService{
    @Autowired
    private OperationRecordMapper recordMapper;

    @Override
    public int saveRecord(OperationRecord operationRecord) {
        return recordMapper.saveRecord(operationRecord);
    }

    @Override
    public List<OperationRecordVO> findByPage(Integer pageNow, Integer rows) {
        int start=(pageNow-1)*rows;
        List<OperationRecordVO> recordList = recordMapper.findVoByPage(start, rows);

        return recordList;
    }

    @Override
    public long findTotal() {
        return recordMapper.findTotal();
    }

    @Override
    public long findByDateTotal(String value) {
        return recordMapper.findByDateTotal(value);
    }

    @Override
    public List<OperationRecordVO> findByDate(Integer pageNow, Integer pageSize, String value) {
        int start=(pageNow-1)*pageSize;
        List<OperationRecordVO> recordList = recordMapper.findByDate(start, pageSize, value);

        //这里为了节省空间，我们查找的对象直接封装为vo对象
//        本来应该是先找record对象，然后封装到vo对象里面的，但是懒得弄，太复杂了，
//        但是这里存的是人物的id，可以拿到人物的id查询数据库，封装到vo对象中
//        for (OperationRecord record : recordList) {
//            OperationRecordVO recordVO=new OperationRecordVO();
//        }

        return recordList;
    }
}




